package com.acc.sys.enums;

import lombok.Getter;
import org.springframework.lang.Nullable;

@Getter
public enum Judge {
    Is(1, "是", true),
    Not(0, "否", false);

    private final Integer code;
    private final String info;
    private final boolean yes;

    private Judge(Integer code, String info, Boolean yes) {
        this.code = code;
        this.info = info;
        this.yes = yes;
    }

    public static boolean getYes(@Nullable Integer code) {
        if (code == null) {
            return Not.yes;
        }
        for (Judge item : Judge.values()) {
            if (item.getCode().equals(code)) {
                return item.yes;
            }
        }
        return Not.yes;
    }

}
